-
Notifications
You must be signed in to change notification settings - Fork 1k
Db client error type for JDBC #13331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...ava/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java
Outdated
Show resolved
Hide resolved
...pentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java
Show resolved
Hide resolved
...pentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java
Outdated
Show resolved
Hide resolved
973784e to
7454b42
Compare
dfd54d9 to
fe0ff1c
Compare
|
@laurit addressed/answered everything - can you check again? |
38a95f0 to
d09a0ae
Compare
0cf2546 to
ae2e7a7
Compare
|
@zeitlinger can you merge in |
ae2e7a7 to
31f9b30
Compare
done |
...ibrary/src/test/java/io/opentelemetry/instrumentation/jdbc/datasource/JdbcTelemetryTest.java
Outdated
Show resolved
Hide resolved
d46e639 to
b0f00f7
Compare
|
@trask works |
trask
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
...ain/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbResponseStatusUtil.java
Outdated
Show resolved
Hide resolved
...o/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java
Show resolved
Hide resolved
…strumentation/jdbc/datasource/JdbcTelemetryTest.java Co-authored-by: Jay DeLuca <[email protected]>
b0f00f7 to
5cf76cb
Compare
|
@trask all done 😄 |
| public String getResponseStatus(@Nullable Response response, @Nullable Throwable error) { | ||
| if (response != null) { | ||
| int httpStatus = response.getStatusLine().getStatusCode(); | ||
| return httpStatus >= 400 && httpStatus < 600 ? Integer.toString(httpStatus) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the intent here is to only use http status codes that are errors. For the same purpose we use slightly different bounds in
Lines 19 to 27 in 81f3795
| CLIENT { | |
| @Override | |
| boolean isError(int responseStatusCode) { | |
| return responseStatusCode >= 400 | |
| || | |
| // invalid status code, does not exists | |
| responseStatusCode < 100; | |
| } | |
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so should we move this to some internal package to promote consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be extracted into a separate util that could also be used from the db instrumentations. Alternatively we could start from having an internal util class that handles the status code for the db instrumentations that use http statuses that behave the same as this code (providing this behavior make sense for the db instrumentations).
| withErrorType( | ||
| "java.lang.IllegalArgumentException", | ||
| equalTo( | ||
| maybeStable(DB_SYSTEM), | ||
| DbIncubatingAttributes.DbSystemIncubatingValues.MEMCACHED), | ||
| equalTo(maybeStable(DB_OPERATION), "decr"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way this cold be approached is using equalTo(ERROR_TYPE, SemconvStability.emitStableDatabaseSemconv() ? "java.lang.IllegalArgumentException" : null)
| public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) { | ||
| try { | ||
| // loaded via reflection, because this class is not available in all versions that we support | ||
| Class<?> ex = Class.forName("io.vertx.pgclient.PgException"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we'd do the Class.forName and getMethod only once and cache the result. Secondly postgres is not the only database supported by vert.x where is the handling for other dbs? It seems that at some point they introduced a common DatabaseException base class, imo you should implement support for at least that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, one extents the other exception
DatabaseException was introduced in 4.4.0, we support 4.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The postgres exception extents Database exception - in later versions of the lib

Part of #12804